<?php
// 检查用户数据
try {
    $pdo = new PDO('sqlite:database/sqlite.db');
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    echo "=== 检查用户数据 ===\n";
    $stmt = $pdo->query("SELECT id, name, card_num, headimg FROM system_member WHERE status = 1");
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo "ID: {$row['id']}, 姓名: {$row['name']}, 卡号: {$row['card_num']}, 头像: {$row['headimg']}\n";
        
        // 检查图片文件是否存在
        if (!empty($row['headimg'])) {
            $imagePath = "public/" . $row['headimg'];
            if (file_exists($imagePath)) {
                echo "  -> 图片文件存在: $imagePath\n";
            } else {
                echo "  -> 图片文件不存在: $imagePath\n";
            }
        }
    }
    
    echo "\n=== 检查数据表结构 ===\n";
    $tables = ['system_member', 'system_checkin_log', 'checkin_device_log'];
    foreach ($tables as $table) {
        try {
            $stmt = $pdo->query("SELECT name FROM sqlite_master WHERE type='table' AND name='$table'");
            if ($stmt->fetch()) {
                echo "✓ 表 $table 存在\n";
            } else {
                echo "✗ 表 $table 不存在\n";
            }
        } catch (Exception $e) {
            echo "✗ 检查表 $table 时出错: " . $e->getMessage() . "\n";
        }
    }
    
} catch (Exception $e) {
    echo "数据库连接错误: " . $e->getMessage() . "\n";
}
